package com.orkhonsoft.tengrinshar.chat.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.NoSuchMessageException;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

@Component
public class LocalMessageSource {

    @Autowired
    private MessageSource messageSource;

    public String getMessage(String code) {
        try {
            String message = messageSource.getMessage(code, null, LocaleContextHolder.getLocale());
            return message;
        } catch (NoSuchMessageException e) {
            return null;
        }
    }
}
